<?php
class Login extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->model("codegen_model");
	}
	function index(){
		$username	= $this->input->post("username");
		$password	= md5($this->input->post("password"));
		$data		= array("USERNAME"=>$username,"PASSWORD"=>$password);
		$result		= $this->codegen_model->get_by("master_user",$data);
		if(!empty($result)){
			$this->session->set_userdata('username', $result[0]['USERNAME']);
			$this->session->set_userdata('password', $result[0]['PASSWORD']);
			$this->session->set_userdata('role', $result[0]['ROLE']);
			redirect("AdminHome");
		} else {
			$this->session->set_flashdata('message', '<div class="error">Username atau Password yang anda masukan salah</div>');
			redirect("/Home");
		}
	}
}
?>